package fhp.hlhj.giantfold.activity.login

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.BaseActivity
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.interfaces.IForget2
import fhp.hlhj.giantfold.javaBean.ChangePwdBean
import fhp.hlhj.giantfold.presenter.ChangePwdPresenter
import fhp.hlhj.giantfold.utils.ToastUtils
import kotlinx.android.synthetic.main.activity_forget2_aty.*

class Forget2Aty : BaseActivity(), IForget2 {
    override fun getContentId(): Int = R.layout.activity_forget2_aty


    private lateinit var presenter:ChangePwdPresenter

    override fun initView() {

        presenter= ChangePwdPresenter(this)
    }

    override fun initListener() {
        btNext.setOnClickListener {
            if (etNewPwd.text.toString().equals(etnewPwdAg.text.toString())){
                val params = HttpParams()
                params.put("phone",intent.getStringExtra("phone"))
                params.put("password",etNewPwd.text.toString())
                presenter.changePwd(params)
            }else{
                ToastUtils.toast(this,"两次输入的密码不一样")
            }
        }
    }
    override fun showLoading() {
    }
    override fun changePwd(changePwdBean: ChangePwdBean) {
        if (changePwdBean.code==200){
            ToastUtils.toast(this,"修改密码成功")
            finish()
        }
    }

}
